package cn.lyjuan.payment.third.base.common.enums.impl;

import cn.lyjuan.payment.third.base.common.enums.ICodeEnum;

public enum IapStatusEnum implements ICodeEnum {
    /**
     * 初始化
     */
    INIT(0, "INIT")
    /**
     * 验证通过
     */
    , OK(1, "OK")
    /**
     * 验证失败
     */
    , NO(2, "NO")
    //
    ;

    private Integer code;

    private String desc;


    public Integer getCode() {
        return code;
    }

    IapStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static IapStatusEnum from(String desc) {
        if (null == desc || desc.length() == 0)
            throw new NullPointerException("desc cannot be null");

        IapStatusEnum[] es = IapStatusEnum.class.getEnumConstants();
        for (IapStatusEnum e : es) {
            if (e.desc.equals(desc))
                return e;
        }
        throw new RuntimeException("unsupported simple status enum: " + desc);
    }
}
